home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gekikoh Dennoh Club 3
/
Gekikoh Dennoh Club Vol. 3 (Japan).7z
/
Gekikoh Dennoh Club Vol. 3 (Japan) (Track 1).bin
/
docs
/
panda
/
splay.c
< prev
next >
Wrap
C/C++ Source or Header
|
1998-02-19
|
7KB
|
392 lines
/*
qv2 play
*/
#include <stdio.h>
#include <stdlib.h>
#include <io.h>
#include <graph.h>
#include <doslib.h>
#include <iocslib.h>
char Y_TBL[65536];
unsigned short gbuf[160*120];
int main(argc,argv)
int argc;
char *argv[];
{
FILE *fp;
int fn,tfn;
short *addr;
// int sx=48,sy=84; //補正しない
int sx=48,sy=38; //補正する
int len;
int ed;
int ssp;
int mode=0;
int st,wt;
screen(1,3,1,1);
if( argc!=3 ){
printf("usage : @>splay file.qv2 wait");
}
CRTMOD(270);
// printf("計算中…\n");
// mktbl();
printf("データ読み込み中…\n");
fp=fopen(argv[1],"rb");
wt=atoi(argv[2]);
len=filelength(fileno(fp));
cls();
ssp=B_SUPER(0);
cls();
ed=len/38400;
while(1){
fseek(fp,0,SEEK_SET);
for( fn=1;fn<=ed;fn++ ){
st=ONTIME();
printf("\x0d%03d ",fn);
// put(sx,sy,sx+159,sy+119,gbuf+19200*(fn-1),38400); //160*120
/*
putQV2wf(sx,sy,gbuf+19200*(fn-1)); //160*120
*/
fread(gbuf,sizeof(short),160*120,fp);
switch( BITSNS(0x00) ){
case 0x00: //
putQV2wn(sx,sy,gbuf); //160*120
printf("no");
break;
case 0x04: //1
putQV2wf(sx,sy,gbuf); //160*120
printf("fi");
break;
/*
case 0x08: //2
putQV2wc(sx,sy,gbuf); //160*120
printf("c0");
break;
case 0x10: //3
putQV2wcc(sx,sy,gbuf); //160*120
printf("cc");
break;
*/
case 0x20: //4
if( fn&1 ){
putQV2wn(sx,sy,gbuf); //160*120
}
else{
putQV2wf(sx,sy,gbuf); //160*120
}
printf("nf");
break;
}
while( st+wt>ONTIME() ){
if( BITSNS(0x00)==0x02 ){
goto quick_exit;
}
}
}
}
B_SUPER(ssp);
quick_exit:;
fclose(fp);
KFLUSHIO(0xff);
}
int mktbl()
{
int col;
int r,g,b,gray;
for( col=0;col<=0xffff;col++ ){
r=(col&0b0000011111000000)>>6;
g=(col&0b1111100000000000)>>11;
b=(col&0b0000000000111110)>>1;
// 0.299 0.587 0.114
r*=1000;
g*=1000;
b*=1000;
gray=r*0.299+g*0.587+b*0.114;
gray/=1000;
Y_TBL[col]=(char)gray;
}
}
//単純補間
int putQV2wn(px,py,addr)
int px,py;
unsigned short *addr;
{
int x,y;
unsigned short *s,*d;
s=addr;
d=(unsigned short *)0xc00000+py*512+px;
for( y=0;y<120;y+=2 ){
//偶数ラインは2重描画
for( x=0;x<20;x++ ){
*d++=*s++;*d++=*s++;*d++=*s++;*d++=*s++;*d++=*s++;*d++=*s++;*d++=*s++;*d++=*s++;
}
d+=352; //512-160
s-=160;
for( x=0;x<20;x++ ){
*d++=*s++;*d++=*s++;*d++=*s++;*d++=*s++;*d++=*s++;*d++=*s++;*d++=*s++;*d++=*s++;
}
d+=352; //512-160
for( x=0;x<20;x++ ){
*d++=*s++;*d++=*s++;*d++=*s++;*d++=*s++;*d++=*s++;*d++=*s++;*d++=*s++;*d++=*s++;
}
d+=352; //512-160
}
}
//櫛形補間
int putQV2wf(px,py,addr)
int px,py;
unsigned short *addr;
{
int x,y;
unsigned short *s,*d;
s=addr;
d=(unsigned short *)0xc00000+py*512+px;
for( y=0;y<120;y+=2 ){
/*
uuuu
udud
dddd
*/
//u
for( x=0;x<20;x++ ){
*(d+512)=*s; *d++=*s++; *d++=*s++;
*(d+512)=*s; *d++=*s++; *d++=*s++;
*(d+512)=*s; *d++=*s++; *d++=*s++;
*(d+512)=*s; *d++=*s++; *d++=*s++;
}
// d+=352; //(512-160)+512
d+=864; //(512-160)+512
//d
for( x=0;x<20;x++ ){
*d++=*s++; *(d-512)=*s; *d++=*s++;
*d++=*s++; *(d-512)=*s; *d++=*s++;
*d++=*s++; *(d-512)=*s; *d++=*s++;
*d++=*s++; *(d-512)=*s; *d++=*s++;
}
d+=352; //512-160
}
}
//色差計算
int putQV2wc(px,py,addr)
int px,py;
unsigned short *addr;
{
int x,y;
unsigned short *su,*sd,*du,*dm,*dd;
unsigned short uc,mc,dc, ur,ug,ub, dr,dg,db, mr,mg,mb;
su=addr;
sd=addr+160;
du=(unsigned short *)0xc00000+py*512+px;
dm=(unsigned short *)0xc00000+py*512+px+512;
dd=(unsigned short *)0xc00000+py*512+px+1024;
for( y=0;y<120;y+=2 ){
//u意味なしか
for( x=0;x<40;x++ ){ *du++=*su++;*du++=*su++;*du++=*su++;*du++=*su++; }
//d
for( x=0;x<40;x++ ){ *dd++=*sd++;*dd++=*sd++;*dd++=*sd++;*dd++=*sd++; }
su-=160;
sd-=160;
for( x=0;x<160;x++ ){
//レジスタがたりんぞい
uc=*su++;
dc=*sd++;
ur=(uc&0b0000011111000000)>>6;
ug=(uc&0b1111100000000000)>>11;
ub=(uc&0b0000000000111110)>>1;
dr=(dc&0b0000011111000000)>>6;
dg=(dc&0b1111100000000000)>>11;
db=(dc&0b0000000000111110)>>1;
mr=((ur+dr)>>1)<<6;
mg=((ug+dg)>>1)<<11;
mb=((ub+db)>>1)<<1;
mc=mr;
mc|=mg;
mc|=mb;
*dm++=mc;
}
du+=1376; //(512-160)+1024
dm+=1376;
dd+=1376;
su+=160;
sd+=160;
}
}
//色差検査後計算orコピー
int putQV2wcc(px,py,addr)
int px,py;
unsigned short *addr;
{
int x,y;
unsigned short *su,*sd,*du,*dm,*dd;
unsigned short uc,mc,dc, ur,ug,ub, dr,dg,db, mr,mg,mb;
su=addr;
sd=addr+160;
du=(unsigned short *)0xc00000+py*512+px;
dm=(unsigned short *)0xc00000+py*512+px+512;
dd=(unsigned short *)0xc00000+py*512+px+1024;
for( y=0;y<120;y+=2 ){
//u意味なしか
for( x=0;x<40;x++ ){ *du++=*su++;*du++=*su++;*du++=*su++;*du++=*su++; }
//d
for( x=0;x<40;x++ ){ *dd++=*sd++;*dd++=*sd++;*dd++=*sd++;*dd++=*sd++; }
su-=160;
sd-=160;
for( x=0;x<160;x++ ){
//レジスタがたりんぞい
uc=*su++;
dc=*sd++;
// printf("%d,",(max((int)Y_TBL[uc],(int)Y_TBL[dc])-min((int)Y_TBL[uc],(int)Y_TBL[dc])));
if( (max((int)Y_TBL[uc],(int)Y_TBL[dc])-min((int)Y_TBL[uc],(int)Y_TBL[dc]))>=12 ){
//37.5%以上の輝度変化があった場合
ur=(uc&0b0000011111000000)>>6;
ug=(uc&0b1111100000000000)>>11;
ub=(uc&0b0000000000111110)>>1;
dr=(dc&0b0000011111000000)>>6;
dg=(dc&0b1111100000000000)>>11;
db=(dc&0b0000000000111110)>>1;
mr=((ur+dr)>>1)<<6;
mg=((ug+dg)>>1)<<11;
mb=((ub+db)>>1)<<1;
mc=mr;
mc|=mg;
mc|=mb;
*dm++=mc;
}
else{
//変化が少なければ上の色をそのまま
*dm++=uc;
}
}
du+=1376; //(512-160)+1024
dm+=1376;
dd+=1376;
su+=160;
sd+=160;
}
}
//色差計算for 68060
int putQV2wc060(px,py,addr)
int px,py;
unsigned short *addr;
{
int x,y;
unsigned short *su,*sd,*du,*dm,*dd;
unsigned short uc,mc,dc, ur,ug,ub, dr,dg,db, mr,mg,mb;
su=addr;
sd=addr+160;
du=(unsigned short *)0xc00000+py*512+px;
dm=(unsigned short *)0xc00000+py*512+px+512;
dd=(unsigned short *)0xc00000+py*512+px+1024;
for( y=0;y<120;y+=2 ){
for( x=0;x<160;x++ ){
uc=*su++;
dc=*sd++;
*du++=uc;
*dd++=dc;
uc&=0b0000011111000000;
uc>>=6;
ur=uc; //@@以下、
ug=(uc&0b1111100000000000)>>11;
ub=(uc&0b0000000000111110)>>1;
dr=(dc&0b0000011111000000)>>6;
dg=(dc&0b1111100000000000)>>11;
db=(dc&0b0000000000111110)>>1;
mr=((ur+dr)>>1)<<6;
mg=((ug+dg)>>1)<<11;
mb=((ub+db)>>1)<<1;
mc=mr;
mc|=mg;
mc|=mb;
*dm++=mc;
}
du+=1376; //(512-160)+1024
dm+=1376;
dd+=1376;
su+=160;
sd+=160;
}
}